<div class="layuimini-main">
    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">客户类型<font color="red">*</font></label>
            <div class="layui-input-block">
                <input type="radio" name="clientType" value="1" title="普通公司" checked="">
                <input type="radio" name="clientType" value="2" title="开发中的客户">
                <input type="radio" name="clientType" value="3" title="已签约的客户">
                <input type="radio" name="clientType" value="4" title="历史客户">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label required">客户编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="id"  placeholder="请输入客户编号" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label required">客户名称<font color="red">*</font></label>
                <div class="layui-input-inline">
                    <input type="text" name="clientName" lay-verify="required" lay-reqtext="客户名称不能为空" placeholder="请输入客户名称" value="" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label required">公司全称</label>
                <div class="layui-input-inline">
                    <input type="text" name="clientName2"  placeholder="请输入公司全称" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label required">公司同行竞争对手</label>
                <div class="layui-input-inline">
                    <input type="text" name="clientOpponent"  placeholder="请输入同行竞争对手" value="" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">行业</label>
            <div class="layui-inline">
                <select name="industry" lay-filter="aihao" lay-search>
                    <option value="">请选择</option>
                    <option value="0">写作</option>
                    <option value="1" selected="">阅读</option>
                    <option value="2">游戏</option>
                    <option value="3">音乐</option>
                    <option value="4">旅行</option>
                </select>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">上班时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="workTime" class="layui-input" placeholder="请输入上班时间">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">城市<font color="red">*</font></label>
            <div class="layui-inline">
                <select name="city" lay-filter="required" lay-search>
                    <option value="">请选择</option>
                    <option value="0">上海</option>
                    <option value="1" selected="">北京</option>
                    <option value="2">浙江</option>
                    <option value="3">四川</option>
                    <option value="4">河北</option>
                </select>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">福利(保险、公积金)</label>
                <div class="layui-input-inline">
                    <input type="text"  name="welfare" class="layui-input" placeholder="请输入福利">
                </div>
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label">公司总机</label>
            <div class="layui-inline">
                <input type="text"  name="companyTel" class="layui-input" placeholder="请输入公司总机">
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">福利(保险、公积金)</label>
                <div class="layui-input-inline">
                    <input  type="text" name="welfare1" class="layui-input" placeholder="请输入福利">
                </div>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">所属文件夹</label>
            <div class="layui-inline">
                <select name="city"  lay-search>
                    <option value="">请选择</option>
                    <option value="0">A</option>
                    <option value="1" selected="">B</option>
                    <option value="2">C</option>
                    <option value="3">D</option>
                    <option value="4">E</option>
                </select>
            </div>
            <div class="layui-inline">
                <input type="radio" name="share" value="1" title="共享" checked="">
                <input type="radio" name="noShare" value="2" title="不共享">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">网址</label>
            <div class="layui-inline">
                <input type="text"  name="website" class="layui-input" placeholder="请输入网址">
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                    <input  type="text" name="email" class="layui-input" placeholder="请输入邮箱">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">上班地址</label>
            <div class="layui-input-block">
                <input  type="text" name="workAddress" class="layui-input" placeholder="请输入上班地址">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">客户简介</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" name="desc"></textarea>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            data.field.id = 2;
            /*var index = layer.alert(JSON.stringify(data.field), {
               title: '最终的提交信息'
            });*/
            _subUrl = '/api/customer/edit.json';

            $.post(_subUrl, JSON.stringify(data.field), function (res) {
                if (res.status == 1) {
                    parent.layer.msg(res.msg, {
                        time: 1000, //1s后自动关闭
                    });
                } else {
                    parent.layer.msg(res.msg, {
                        time: 1000, //1s后自动关闭
                    });
                    return false;
                }
            }, "json")
        }, function () {

            // 关闭弹出层
            layer.close(index);
            layer.close(parentIndex);

        });
        return false;
    });
</script>
